{include file="public/header" title="签到"/}
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">签到</h1>
    <!--<a href="" class="mui-btn-link mui-pull-right">明细</a>-->
</header>

<div class="mui-content layui-clear" id="my_sign">
    <div class="info">

        <h4>签到奖励提示</h4>
        <p>每天签到，获得积分奖励</p>
        <div id="sign">
            <h4><span class="sun sun-ziyuan"></span>{$data['date']}</h4>
            <ul class="layui-clear">
                <!--星期-->
                {foreach name="data['week']" id="value"}
                <li class="title">{$value}</li>
                {/foreach}
                <!--开始位空行-->
                {for start="0" end="$data['start_week']"}
                <li class="sign"></li>
                {/for}
                <!--当月天数行-->
                {for start="0" end="$data['days']"}
                    {if condition="($i+1) < $data['day']"}
                        {in name="$i+1" value='$sign'}
                            <li class="sign error ok">{$i+1}</li>
                        {else/}
                            <li class="sign error">{$i+1}</li>
                        {/in}
                    {elseif condition="($i+1) > $data['day']"/}
                        <li class="sign success">{$i+1}</li>
                    {elseif condition="($i+1) == $data['day']"/}
                        {in name="$i+1" value='$sign'}
                            <li class="sign this ok" id="ok_{$data['day']}">{$i+1}</li>
                        {else/}
                            <li class="sign this" id="ok_{$data['day']}">{$i+1}</li>
                        {/in}
                    {/if}
                {/for}
                <!--结束位空行-->
                {for start="0" end="7-$data['start_week']"}
                <li class="sign"></li>
                {/for}
            </ul>
            <div>
                <a class="layui-btn layui-btn-sm" onclick="signs('#ok_{$data[\'day\']}')">签到</a>
            </div>
        </div>
    </div>
</div>
<script>
    (function ($) {
        $.init({
            swipeBack: true //启用右滑关闭功能
        });
    })(mui);
    var $ = layui.$, form = layui.form;

    function signs(obj) {
        $.post("{:url('my_sign')}", function (response) {
            mui.toast(response.msg, {duration: 3000, type: 'div'});
            if (response.code === 200) {
                if (!$(obj).hasClass('ok')) {
                    $(obj).addClass('ok');
                }
            }
        });
    }
</script>
{include file="public/footer"/}